package com.ruoyi.web.controller.saas;

import com.bonuo.saas.domain.LogBook;
import com.bonuo.saas.domain.ProblemSummary;
import com.bonuo.saas.service.LogBookService;
import com.bonuo.saas.service.ProblemSummaryService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "问题汇总管理")
@RestController
@RequestMapping("/saas/problemSummary")
public class ProblemSummaryController extends BaseController {

    @Autowired
    private ProblemSummaryService problemSummaryService;

    @ApiOperation(value = "查询问题汇总列表",httpMethod = "GET")
    @GetMapping("/list")
    public AjaxResult list(ProblemSummary problemSummary, Integer pageNum, Integer pageSize){
        if(pageNum != null && pageSize != null){
            PageHelper.startPage(pageNum,pageSize);
        }
        List<ProblemSummary> list = problemSummaryService.selectProblemSummaryList(problemSummary);
        return success(new PageInfo<>(list));
    }

    @ApiOperation(value = "添加问题汇总",httpMethod = "POST")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody ProblemSummary problemSummary){
        Integer add = problemSummaryService.insertProblemSummary(problemSummary);
        return toAjax(add);
    }

    @ApiOperation(value = "修改问题汇总",httpMethod = "PUT")
    @PutMapping("/update")
    public AjaxResult edit(@RequestBody ProblemSummary problemSummary){
        Integer update = problemSummaryService.updateProblemSummary(problemSummary);
        return toAjax(update);
    }

    @ApiOperation(value = "删除问题汇总",httpMethod = "DELETE")
    @DeleteMapping("/delete/{id}")
    public AjaxResult delete(@PathVariable Integer id){
        Integer delete = problemSummaryService.deleteProblemSummaryById(id);
        return toAjax(delete);
    }
}
